import 'sightable.dart';
import 'eventable.dart';

class Living extends Sightable {
  int maxVitality = 100;
  int vitality = 100;
  int attackPower = 10;
  Living(Map map) : super((map??{})['name']){
    if (map == null) { map = {}; }
    Map data = {...map, 'maxVitality': '100', 'attackPower': '10'};
    code = map['code'];
    this.maxVitality = int.parse(data['maxVitality']);
    this.vitality = this.maxVitality;
    this.attackPower = int.parse(data['attackPower']);
    // this.add(Eventable('查看'));
  }

  @override
  void copyData(dynamic obj) {
    super.copyData(obj);
    this.maxVitality = obj.maxVitality;
    this.vitality = this.maxVitality;
    this.attackPower = obj.attackPower;
  }

  void onVictory(){
    this.vitality = this.maxVitality;
  }

  void onDefeated(){
    this.vitality = this.maxVitality;
  }
}